import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login'
import Register from '../views/register'
import Home from '../views/home'
import Manager from '../views/manager'
import BusinessRegister from "@/components/myShop/businessRegister"
import MyShop from '../components/myShop/myShop'
import ProductList from '@/components/main/mainPage'
import ProductDetail from '@/components/main/productDetail'
import CheckOut from '@/components/cart/checkOut'
import ShopDetail from '@/components/myShop/shopDetail'
import Settlement from '@/components/cart/settlement'
import UserPage from '@/components/user/userPage'
import Completed from '@/components/cart/completed'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    redirect: {name:'Home'}
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    redirect: {name: 'ProductList'},
    children: [
      {
        path: 'productList',
        name: 'ProductList',
        component: ProductList
      },
      {
        path: 'myShop',
        name: 'MyShop',
        component: MyShop
      },
      {
        path: 'br',
        name: 'BusinessRegister',
        component: BusinessRegister
      },
      {
        path: 'productDetail',
        name: 'ProductDetail',
        component: ProductDetail
      },
      {
        path: 'checkOut',
        name: 'CheckOut',
        component: CheckOut
      },
      {
        path: 'settlement',
        name: 'Settlement',
        component: Settlement
      },
      {
        path: 'shop/:shopId/:shopName',
        name: 'ShopDetail',
        component: ShopDetail
      },
      {
        path: 'userInfo',
        name: 'UserPage',
        component: UserPage
      },
      {
        path: 'completed',
        name: 'Completed',
        component: Completed
      }
    ]
  },
  {
    path: '/manager',
    name: 'Manager',
    component: Manager
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach()

export default router
